<template>
  <div class="header">
    <span>下载</span>
    <div class="headIcon">
      <img src="" alt="" />
      <p>{{ userName }}</p>
      <ul class="drow-down">
        <li>我的</li>
        <li @click="loginOutHandler">退出</li>
      </ul>
    </div>
  </div>
</template>

<script>
import { mapState, mapGetters, mapMutations, mapActions } from "vuex";
export default {
  name: "writeHeader",
  props: {
    msg: String,
  },
  data() {
    return {
      property: "value",
    };
  },
  computed: {
    ...mapState("login", ["userName"]),
  },
  created() {},
  methods: {
    ...mapActions("login", ["loginOut"]),
    loginOutHandler() {
      this.loginOut();
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 60px;
  border: 1px solid #ccc;
  .headIcon {
    height: 40px;
    position: relative;
    > img {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      border: 1px solid #ccc;
    }
    > p {
      color: #222;
    }
    .drow-down {
      height: 0;
      overflow: hidden;
    }
  }
  .headIcon:hover .drow-down {
    transition: all 1s;
    position: absolute;
    top: 40px;
    left: 0;
    width: 35px;
    height: auto;
    border: 1px solid #ccc;
    box-shadow: 1px 1px 1px 1px #ccc;
    > li {
      margin: 4px auto;
      border-bottom: 1px solid #ccc;
    }
  }
}
</style>
